package 康复训练_JavaGo并驾齐驱;

import 二叉树.TreeNode;

public class Jz28对称的二叉树 {

    public boolean isSymmetric(TreeNode root) {

        if (root == null) {
            return true;
        }

        return this.dg(root.left, root.right);
    }

    private boolean dg(TreeNode A, TreeNode B) {
        if (A == null && B == null) {
            return true;
        }
        if (A == null || B == null) {
            return false;
        }
        if (A.val != B.val) {
            return false;
        }
        return this.dg(A.left, B.right) && this.dg(A.right, B.left);
    }

}
